package com.xie.mapper;

import com.xie.pojo.User;
import org.apache.ibatis.annotations.*;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface UserMapper extends Mapper<User> {
    @Select("select * from user where name = #{username}")
    @Results({
            @Result(id = true, property = "id", column = "id"),
            @Result(column = "name", property = "name"),
            @Result(column = "email", property = "email"),
            @Result(column = "password", property = "password"),
            @Result(column = "money", property = "money"),
            @Result(column = "id", property = "roles", javaType = List.class, many =
            @Many(select = "com.xie.mapper.RoleMapper.findRoleByUserId")) })
    User findByUserName(String username);


    @Select("select count(1) from user_wap where uid=#{id}")
    int findZyByIdCount(Integer id);

    @Select("select count(1) from zy where upload=#{name}")
    int findZyByUserCount(String name);

    @Select("select count(1) from user_wap where zid=#{id} and uid=#{uid}")
    int checkWap(Integer id, Integer uid);

    @Insert("insert into user_wap values(#{uid},#{zid})")
    void insertUserZy(Integer uid, Integer zid);
}
